TimeStamp Extension
version 0.10
Actions
This extension has no actions.
Conditions
This extension has no conditions.
Expressions
Today Stamp("TimeStamp object")
Gets the timestamp of the current time.
Time Stamp("TimeStamp object", Year, Month, Day, Hours, Minutes, Seconds)
Converts separate values into a single Timestamp value.
Note that the parameters for this function are in local time and timestamps are in UTC (0 timezone), so TimeStamp(2000,1,1,0,0,0) will give a different timestamp depending what timezone the user's pc is set to.
Timezone("TimeStamp object")
Gets the computer's timezone.
TSYearDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts TimeStamp2 from TimeStamp1 and returns the number of whole years difference.
This and the following all return their part of a date difference, so it calculates that 12:01:01 minus 12:00:00 is "1 minute and 1 second", not "1 minute or 61 seconds". If the second date is later then the difference will be negative.
Note that these functions take daylight savings time into consideration, so midnight december 15 (non-dst) minus midnight june 15 (dst) is 6 months and 1 hour.
TSMonthDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts and returns the number of months difference.
TSDayDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts and returns the number of days difference.
TSHoursDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts and returns the number of hours difference.
TSMinutesDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts and returns the number of minutes difference.
TSSecondsDiff("TimeStamp object", TimeStamp1, TimeStamp2)
Subtracts and returns the number of seconds difference.
TSYear("TimeStamp object", TimeStamp)
Extracts the year from a Timestamp.
This and the following work in local time, so will return different dates and times depending on the current timezone of the user's pc.
TSMonth("TimeStamp object", TimeStamp)
Extracts the month from a Timestamp.
TSDay("TimeStamp object", TimeStamp)
Extracts the day from a Timestamp.
TSHours("TimeStamp object", TimeStamp)
Extracts the hours from a Timestamp.
TSMinutes("TimeStamp object", TimeStamp)
Extracts the minutes from a Timestamp.
TSSeconds("TimeStamp object", TimeStamp)
Extracts the seconds from a Timestamp.
TSDayofWeek("TimeStamp object", TimeStamp)
Extracts the day of the week from a Timestamp.
AddYears("TimeStamp object", TimeStamp, y)
Adds y years to a Timestamp.
Note that these functions adjust for daylight savings time, so midnight December 15 (non-dst) plus 6 months equals 1am June 15 (dst).
AddMonths("TimeStamp object", TimeStamp, m)
Adds m months to a Timestamp.
AddWeeks("TimeStamp object", TimeStamp, w)
Adds w weeks to a Timestamp.
AddDays("TimeStamp object", TimeStamp, d)
Adds d days to a Timestamp.
AddHours("TimeStamp object", TimeStamp, h)
Adds h hours to a Timestamp.
AddMinutes("TimeStamp object", TimeStamp, m)
Adds m minutes to a Timestamp.
AddSeconds("TimeStamp object", TimeStamp, s)
Adds s seconds to a Timestamp.
Full Date String("TimeStamp object", TimeStamp)
Converts a Timestamp into a text string.
TSYYYYMMDD("TimeStamp object", TimeStamp)
Converts a Timestamp into a "YYYYMMDD" form text string.
TSHHMMSS("TimeStamp object", TimeStamp)
Converts a Timestamp into a "HHMMSS" form text string.
TS_Str$("TimeStamp object", TimeStamp)
Converts a Timestamp into a string that correctly represents the Timestamp. May return a different string to MMF's Str$() if the timestamp is in the extended date range, which mmf sees as negative.
TS_Val("TimeStamp object", String)
Converts a string into the correct Timestamp. May return a different value to MMF's Val() if the number in the string is a larger positive number than mmf can understand, as this function will read the number as being part of the extended timestamp range, which mmf sees as negative.
Notes
All number functions return -1 on error, all text functions return "Error: ..." on error.
All Add???() expressions take daylight savings into account, so, for example, adding 2 hours to midnight October 31 2004 gives 1am.
Known issues
Timestamps for after the year 2001 don't fit in an mmf counter, so global/local values or strings (or other storage) must be used.
Timestamps between 0 and 2147483647 are the standard range and represent Jan 01 1970, 0:00:00 to Jan 19 2038, 3:14:07.
Timestamps between -2147483648 to -2 are the extended range and represent Jan 19 2038, 3:14:08 to Feb 07 2106, 6:28:14. TS_Str$ and TS_Val() should be used to translate these to or from the correct (positive number) string representation.
Technical Notes
This extension's extended date range compared to the range of normal 32-bit timestamps is because normal 32-bit timestamps only use positive numbers, and assume all negative numbers are errors. This means that they are effectively only using 31 bits. This extension uses 64-bit timestamps internally and returns the smallest 32-bits to mmf, and if the timestamp is larger than 32-bits then it returns -1. This means that it uses all 32 bits, however mmf only supports signed numbers so if the highest bit is set the number shows as negative.
Normally you won't be able to directly transfer a negative (extended-range) timestamp to another program, because the program will treat it as an error. To transfer it successfully, verify that the other program uses 64-bit timestamps and then either use the
TS_Str$() expression to output your timestamp as text correctly, or use the binary object or similar to write a binary 64-bit number with your timestamp in the lower 32-bits and 0 in the upper.
Changelog
0.10
Added support for extended timestamps, this doubles the range of dates that can be used to 136 years (1970-2106). The extra range shows up as negative numbers in mmf.
Added TS_Str$() to convert a timestamp to a string containing a positive number. This string will be compatible with any programs that read timestamps from strings and understand 64-bit timestamps.
Added TS_Val() to convert a string containing a number to a timestamp, as the reverse of TS_Str$().
Fixed the TS???Diff() and TSAddDays() expressions so that they all understood daylight savings time and didn't occassionally return negative numbers when they shouldn't (especially TSDayDiff()).
Changed the example to use the two new functions.
0.9c
Fixed a bug with the month being 0-based in TSYYYYMMDD().
0.9b
Fixed a bug with treatment of daylight savings time in TSMonthDiff() and TSDayDiff().
0.9
Added TSYearDiff(), TSMonthDiff(), TSWeekDiff(), TSDayDiff(), TSHoursDiff(), TSMinutesDiff(), TSSecondsDiff() functions.
Modified example to show TS...Diff() functions working, added example link to docs.
0.8d2
Major Fix: Extension was found to need MSVCR71.dll, which is only present on Windows XP SP2 (and above, I guess). Build options changed to include the necessary code in the extension instead of using the dll, but the size of the extension is now 43KB for the run-only version instead of 9KB.
0.8d
Added TSHHMMSS() function.
Changed credits to read "has been released" instead of "will be released".
0.8c
Added TSYYYYMMDD() function.
Added jpcr and joewski to credits for their feature requests.
0.8b
Added Timezone() function.
Added version detection to the extension, it will now tell you if you are loading a cca made with a newer version of the extension.
0.8
Added Full Date String() function.
Added AddYears(), AddMonths(), AddWeeks(), AddDays(), AddHours(), AddMinutes(), AddSeconds() functions.
Fixed Help button on setup dialog, now looks relative to mmf install dir not current dir.
Example no longer requires the Cellosoft Timer Object. YAY!!!
0.7c
Fixed bug introduced in 0.7b, the TSYear()... etc. functions would return -1 almost all the time, instead of just on error.
0.7b
Used build_small configs, filesize now 16kB for edit-time and 6.5kB for run-only (was 56 / 52).
Added changelog to help file.
Fixed version information in TimeStamp.cox.
Changed output of TSYear()... etc. functions to be -1 on error.
0.7
Added Today Stamp() and TSDayofWeek() functions
Added help file and enabled Help button.
0.6
Added TSYear(), TSMonth(), TSDay(), TSHours(), TSMinutes(), TSSeconds() functions.
Fixed a bug with treatment of daylight savings time.
Changed Month to 1-based instead of 0-based.
0.5
First release, only Time Stamp() function existed. (dunno why it wasn't 0.1)